//
//  XFYRobotMemory.m
//  MyRobotApp
//
//  Created by 小肥羊 on 15/5/29.
//  Copyright (c) 2015年 小肥羊. All rights reserved.
//

#import "XFYRobotMemory.h"

@implementation XFYRobotMemory
#pragma mark - 初始化
- (id)initMemory:(NSString *)owner
{
    self = [super init];
    if (self) {
        _memory = [[XFYLocalData alloc] initWithPath:owner];
        [_memory openDB];
    }
    return self;
}


#pragma mark - 记得
- (void)remember:(NSString *)message
{
    [self.memory addMessageMemory:[NSDate new] Content:message];
}

- (void)AllMemories
{
    FMResultSet *data = [self.memory searchAllMessageMemory];
    NSLog(@"我所记得的东西，但是我并不知道这是什么:");
    while ([data next]) {
        NSDate *date = [data dateForColumn:@"MessageMemoryDate"];
        NSString *content = [data objectForColumnName:@"MessageMemoryContent"];
        NSLog(@"%@：%@",date,content);
    }
}

- (NSArray *)AllCognition
{
    NSMutableArray *cognitionArray = [[NSMutableArray alloc] init];
    FMResultSet *data = [self.memory searchAllCognition];
    while ([data next]) {
        NSString *date = [data objectForColumnName:@"Cognition"];
        NSString *tableName = [data objectForColumnName:@"CognitionTableName"];
        NSDictionary *dict = @{@"Cognition":date,@"CognitionTableName":tableName};
        [cognitionArray addObject:dict];
    }
    return cognitionArray;
}
@end
